Amber's Digital Garden

Git SSH Setup

My best understanding of how to set up ssh with git.


Check to make sure you don't already have a SSH key pair.

  1. They will probably be in ~/.ssh on Linux, and C:/Users/<username>/.ssh on Windows.
  2. They'll look something like id_ed25519 (the private key), and id_ed25519.pub (the public key):
    1. ![[Pasted image 20260812114858.png]]
  3. If you don't have any SSH keys here, generate them with ssh-keygen -t ed25519 -a 100. Afterwards, the keys should appear.

Tell the server about the key

  1. Go to your git hosting provider, and follow their instructions to add the contents of the public key.
    1. for git.gay, it looks like this:
      1. Go to https://git.gay/user/settings/keys
      2. "Add Key"
      3. Name the key after the device it will be used from
      4. Paste the contents of the Public Key in "Content" and confirm.
      5. You can then verify the key by providing the contents of the private key.
  2. Next, you must tell set up your local machine to use the keys.
    1. Add the Private key ssh-add /path/to/private/key
    2. In your terminal, run the following commands:
    3. Make git use SSH to sign commits and tags: git config set --global gpg.format ssh
    4. Set the SSH signing key to your public key: git config set --global user.signingKey '/path/to/public/key.pub'
    5. Sign commits by default: git config set --global commit.gpgSign true

Update local repositories to use the key

  1. Finally, if the git repo was not set up with the key from the start, you will need to update it to use the key (I guess????)
    1. cd /path/to/repo
    2. `git remote -v
    3. If the URL starts with https://, you will need to change it to the SSH format. To do this, use the following command, replacing username and repository with your GitHub username and repository name:
      1. git remote set-url origin git@YourHostingProvider.com:username/repository.git
    4. Verify it updated: git remote -v

In theory, it should now work!

I hate this

Sources:


by amber